{include file="common/header"/}
<div class="fadeInUp animated headalert"><br>
    <div class="layui-anim layui-anim-up">
        <form class="layui-form">
            <div class="layui-container">
                <div class="layui-row">
                    <div class="layui-form-item">
                      <label class="layui-form-label">用户组名</label>
                      <div class="layui-input-4">
                        <input type="text" name="title" autocomplete="off" placeholder="请输入用户组名" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btns layui-btn-blue" lay-submit="" lay-filter="index">添加</button>
                        <button type="reset" class="layui-btn layui-btns layui-btn-primary">重置</button>
                      </div>
                    </div>
              </div>
            </div>
        </form>
    </div>   
</div> 
{include file="common/footer"/}
<script>
var time = {:time()};
var url = '{:url("index")}';
layui.use(['form','layer','element'], function(){
    var form = layui.form
    ,layer = layui.layer
    ,element = layui.element
    ,$ = layui.jquery;
    //监听提交
    form.on('submit(index)', function(data){
        data.field.time = time;
        $.ajax({
            url:url,
            type:"POST",
            data:data.field,
            dataType:"json",
            headers: {token: 123456},
            success:function(res){
                console.log(res);
                if(res.code == 1){
                    layer.msg(res.msg);
                      setTimeout(function(){
                          window.parent.location.reload();//修改成功后刷新父界面
                    }, 1000);
                }else{
                  layer.msg(res.msg); 
                }
            },
            error:function(){
                layer.msg('请求失败');     
            },
        });
        return false;
    /*  $.ajax({
      type:'post',
      url:url1,   
      data:{data.field},
      dataType: "json",
      success:function(msg){
        console.log(msg);
      },
      error:function () {
        layer.alert('请求失败了', {icon: 5});
      }
    });*/
      /*  $.ajax({ 
            url: url,
            data:{data.field},
            dataType: "json",
            type: "POST",
            success:function(res){
              console.log(res);
            }


        });
*/
     /* $.post(url,data.field,function(res){
          if(res.code == 1){
            layer.msg(res.msg);
              setTimeout(function(){
                  window.parent.location.reload();//修改成功后刷新父界面
            }, 1000);
          }else{
            layer.msg(res.msg); 
          }
      },'json')*/
        
    }); 
});
</script>
